package com.ruoyi.system.dao;

import java.io.Serializable;
import java.util.List;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import com.ruoyi.system.domain.SysRoleUser;

@Repository
public interface SysRoleUserDAO
		extends JpaRepository<SysRoleUser, String>, JpaSpecificationExecutor<SysRoleUser>, Serializable {

	public int countByRoleId(String roleId);


	public int deleteByRoleId(String roleId);

	@Modifying
	@Query(value = "delete from sys_role_user where user_id =?1 and role_id =?2 ", nativeQuery = true)
	public int deleteUserRoleInfo(String userId, String roleId);

	@Modifying
	@Query(value = "delete from sys_role_user where user_id in (:userIds) and role_id = :roleId ", nativeQuery = true)
	public int deleteUserRoleInfos(@Param("roleId") String roleId, @Param("userIds") List<String> userIds);

	@Modifying
	@Query(value = "delete from sys_role_user where user_id=?1 ", nativeQuery = true)
	public int deleteUserRoleByUserId(String userId);


	public List<SysRoleUser> findByRoleId(String roleId);
}
